---
id: 6582575b8089f85b8b92d7c8
title: الخطوة 33
challengeType: 20
dashedName: step-33
---

# --description--

After getting the expense details, you need to call the `add_expense` function to add the new expense to the `expenses` list.

After getting the `amount` and `category` using `input()`, call the `add_expense` function, passing three arguments: `expenses`, `amount` and `category`.

- `expenses` is the empty list created in the main function earlier in this project.
- `amount` is the amount of the expense.
- `category` is the category of the expense.

# --hints--

You should have `add_expense(expenses, amount, category)` in your `if` statement.

```js
({ test: () =>
  {
    const transformedCode = code.replace(/\r/g, "");        
    const foo = __helpers.python.getDef("\n"+transformedCode, "main");
    const {function_body} = foo;    
    assert(function_body.match(/^\s+if\s+choice\s*==\s*("|')1\1\s*:\s*amount\s*=\s*float\s*\(\s*input\s*\(\s*("|')Enter\samount:\s\2\s*\)\s*\)\s*category\s*=\s*input\s*\(\s*("|')Enter\scategory:\s\3\s*\)\s*add_expense\s*\(\s*expenses\s*,\s*amount\s*,\s*category\s*\)/m));
  }
})
```

# --seed--

## --seed-contents--

```py
def add_expense(expenses, amount, category):
    expenses.append({'amount': amount, 'category': category})

def print_expenses(expenses):
    for expense in expenses:
        print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')

def total_expenses(expenses):
    return sum(map(lambda expense: expense['amount'], expenses))

def filter_expenses_by_category(expenses, category):
    return filter(lambda expense: expense['category'] == category, expenses)


def main():
    expenses = []
    while True:
        print('\nExpense Tracker')
        print('1. Add an expense')
        print('2. List all expenses')
        print('3. Show total expenses')
        print('4. Filter expenses by category')
        print('5. Exit')

        choice = input('Enter your choice: ')
--fcc-editable-region--
        if choice == '1':
            amount = float(input('Enter amount: '))
            category = input('Enter category: ')

--fcc-editable-region--
```
